package com.zmn.oms.services.impl.purpose;

import com.zmn.oms.model.entity.purpose.OrderPurpose;
import com.zmn.oms.model.entity.purpose.OrderPurposeQuery;
import com.zmn.oms.persistence.interfaces.purpose.OrderPurposeDao;
import com.zmn.oms.services.interfaces.purpose.OrderPurposeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 类描述：意向单
 *
 * @author liuying
 * @date 2018/11/06 11:41
 */
@Service
public class OrderPurposeServiceImpl implements OrderPurposeService {

    @Resource
    private OrderPurposeDao purposeDao;


    @Override
    public List<OrderPurpose> listOrderPurpose(OrderPurposeQuery query) {
        // 查询总额
        int count = purposeDao.countOrderPurpose(query);
        query.setTotalCount(count);
        // 查询列表
        return count == 0 ? new ArrayList<>(0) : purposeDao.listOrderPurpose(query);
    }

    @Override
    public void insertOrderPurpose(OrderPurpose orderPurpose) {
        purposeDao.insertOrderPurpose(orderPurpose);
    }

    @Override
    public void updateOrderPurpose(OrderPurpose orderPurpose) {
        purposeDao.updateOrderPurpose(orderPurpose);
    }

    @Override
    public OrderPurpose findOrderPurposeByKey(Integer orderPurposeId) {
        return purposeDao.findOrderPurposeByKey(orderPurposeId);
    }
}
